<?php
class ApiModel
{
    public function __construct()
    {
        $this->db = Yaf_Registry::get('db');
        //$this->time = date("Y-m-d H:i:s",time());
    }

    /*改变订单状态
     *$orderid
     */
    public function changeStatus($orderid){
        $sql = "update `order` set status=3 where status=0 and id='".$orderid."'";
       // print_r($sql);
        return $this->db->query($sql);
    }
    /*改变订单队列状态
     *$orderid
     */
    public function changeDuilieStatus($orderid){
        $sql = "update `order` set duiliestatus=1 where duiliestatus=0 and id='".$orderid."'";
        // print_r($sql);
        return $this->db->query($sql);
    }
    /*改变订单队列状态
        *$orderid
        */
    public function goCart($userid){
        $sql = "delete from `cart` where user_id='".$userid."'";
        // print_r($sql);
        return $this->db->query($sql);
    }

    /*生成当前用户收益记录
     * $userid,$num,$son_userid
     */
    public function fanyongRecord($userid,$num,$son_userid){  //生成当前用户收益记录
        $sql="INSERT `asset` (`profit`, `status`, `serial_num`, `datatime`, `my_id`, `son_id`) VALUES ({$num}, '1', 445, ".time().", {$userid}, {$son_userid})";

        return $this->db->query($sql);
    }

    /*当前用户增加账户金额
     * $userid,$num
     */
    public function fanyongAdd($userid,$num){
        $sql="update `user` set `amount`=`amount`+{$num} where `user_id`={$userid}";
        print_r($sql);
        return $this->db->query($sql);
    }

    /*查询用户信息根据uid
    * $userid
    */
    public function getUserinfo($userid){
        $sql = "select * from `user` where user_id=".$userid;
        return $this->db->get_one($sql);
    }






}


